<?php

class Tindaklanjut{

	private $id;
	private $kd_sm;
	private $tindaklanjut;
	private $penindaklanjut;
	private $waktu;
	
	
	function __construct(){}
	
	function setId($id){
		$this->id = $id;
	}
	
	function setKd_sm($kd_sm){
		$this->kd_sm = $kd_sm;
	}
	
	function setPenindaklanjut($penindaklanjut){
		$this->penindaklanjut = $penindaklanjut;
	}
	
	function setTindaklanjut($tindaklanjut){
		$this->tindaklanjut = $tindaklanjut;
	}
	
	function setWaktu($waktu){
		$this->waktu = $waktu;
	}
	
	function getId(){
		return $this->id;
	}
	
	function getKd_sm(){
		return $this->kd_sm;
	}
	
	function getPenindaklanjut(){
		return $this->penindaklanjut;
	}
	
	function getTindaklanjut(){
		return $this->tindaklanjut;
	}
	
	function getWaktu(){
		return $this->waktu;
	}
}

class Daftar_tindaklanjut{
	
	function __construct(){}
	
	function getAll(){
		
		$sql="
			select * from tindaklanjut
		";
		
		$list_Tindaklanjut = array();
		
		$data = mysql_query($sql);
		if($data){
			while($row = mysql_fetch_assoc($data)){
			
				$Tindaklanjut = new Tindaklanjut();
				$Tindaklanjut->setId($row['kd_Tindaklanjut']);
				$Tindaklanjut->setKd_sm($row['kd_sm']);
				$Tindaklanjut->setPenindaklanjut($row['Penindaklanjut']);
				$Tindaklanjut->setTindaklanjut($row['tindaklanjut']);
				$Tindaklanjut->setWaktu($row['waktu_tindaklanjut']);
	
				$list_Tindaklanjut[] = $Tindaklanjut;
			}
		}	
		return $list_Tindaklanjut;
	
	}
	
	function getBySM($kd_sm){
		
		$sql="
			select * from tindaklanjut where kd_sm = '$kd_sm'
		";
		
		$list_tindaklanjut = array();
		
		$data = mysql_query($sql);
		if($data){
			while($row = mysql_fetch_assoc($data)){
			
				$Tindaklanjut = new Tindaklanjut();
				$Tindaklanjut->setId($row['kd_tindaklanjut']);
				$Tindaklanjut->setKd_sm($row['kd_sm']);
				$Tindaklanjut->setPenindaklanjut($row['penindaklanjut']);
				$Tindaklanjut->setTindaklanjut($row['tindaklanjut']);
				$Tindaklanjut->setWaktu($row['waktu_tindaklanjut']);
	
				$list_tindaklanjut[] = $Tindaklanjut;
			}
		}	
		return $list_tindaklanjut;
	
	}
	
	function getById($id){
		
		$sql="
			select * from tindaklanjut where kd_tindaklanjut = '$id'
		";
		
		$data = mysql_query($sql);
		if($data){
			while($row = mysql_fetch_assoc($data)){
			
				$Tindaklanjut = new Tindaklanjut();
				$Tindaklanjut->setId($row['kd_tindaklanjut']);
				$Tindaklanjut->setKd_sm($row['kd_sm']);
				$Tindaklanjut->setPenindaklanjut($row['penindaklanjut']);
				$Tindaklanjut->setTindaklanjut($row['tindaklanjut']);
				$Tindaklanjut->setWaktu($row['waktu_tindaklanjut']);
	
			}
		}	
		return $Tindaklanjut;
	
	}
	
	function add(Tindaklanjut $tindaklanjut){
	
		$sql="
		insert into tindaklanjut(kd_tindaklanjut, kd_sm, penindaklanjut, tindaklanjut, waktu_tindaklanjut)
		values(
		'',
		'".$tindaklanjut->getKd_sm()."',
		'".$tindaklanjut->getPenindaklanjut()."',
		'".$tindaklanjut->getTindaklanjut()."',
		'".$tindaklanjut->getWaktu()."'
		)
		";
		
		$query=mysql_query($sql);

	}
	
	function edit(Tindaklanjut $tindaklanjut){
		$sql="UPDATE tindaklanjut SET
		tindaklanjut = '".$tindaklanjut->getTindaklanjut()."'
		WHERE 
		kd_tindaklanjut='".$tindaklanjut->getId()."'
		";
		$query=mysql_query($sql);
		//var_dump($posisi_surat);
	}
	
	
	function delete($id){
		$sql="
		delete from tindaklanjut where kd_tindaklanjut = '$id'		
		";
		$query = mysql_query($sql);
		return $query;
	}

	
	
	

}